#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Create by zhang
# Create on 2022/6/22 10:36
from typing import List

from domain.report.common.period_enum import PeriodEnum
from domain.report.dto.topten_dto import TopTenDTO
from domain.report.common.datasource_config import DataType, DataSource, SpiderType

if DataSource.spider_type == SpiderType.xbrl_sse:
    if DataSource.data_type == DataType.json:
        from domain.report.repository.impl.xbrl_sse.json import topten_repository_json as repo
elif DataSource.spider_type == SpiderType.xueqiu:
    if DataSource.data_type == DataType.json:
        from domain.report.repository.impl.xueqiu.json import topten_repository_json as repo


def insert(dto:TopTenDTO) -> bool:
    return repo.insert(dto)


def insert_batch(dto_list:List[TopTenDTO]) -> bool:
    return repo.insert_batch(dto_list)


def get(stock_code:str, year:int, period:PeriodEnum) -> TopTenDTO:
    return repo.get(stock_code, year, period)


def contain(dto:TopTenDTO) -> bool:
    return repo.contain(dto)